class CreateItemsForLinkouts < ActiveRecord::Migration
  def self.up
    #Create data providers NASA, ARNAT and USDA
    
    nasa_data_provider =
    DataProvider.new(
    :name=> "NASA",
    :risk_disclaimer => "No risk disclaimer applicable.",
    :logo=> "",
    :copyright_notice=> "Works by NASA are in the public domain.",
    :acknowledgement => "This data provided by NASA.",
    :home_url => "http://www.nasa.gov/",
    :full_name => "National Aeronautics and Space Administration"
    )
    nasa_data_provider.save!

    arnat_data_provider = 
      DataProvider.new(
        :name=> "ARNAT",
        :risk_disclaimer => "No risk disclaimer applicable.",
        :logo=> "",
        :copyright_notice=> "Copyright Australian Research Network for Algal Toxins, used with permission.",
        :acknowledgement => "This data provided by the Australian Research Network for Algal Toxins.",
        :home_url => "http://www.aims.gov.au/arnat/arnat-00001.htm",
        :full_name => "Australian Research Network for Algal Toxins"
      )
    arnat_data_provider.save!

    usda_data_provider = 
      DataProvider.new(
        :name=> "USDA",
        :risk_disclaimer => "No risk disclaimer applicable.",
        :logo=> "",
        :copyright_notice=> "Works by the USDA are in the public domain.",
        :acknowledgement => "This data provided by the USDA.",
        :home_url => "http://www.usda.gov/",
        :full_name => "United States Department of Agriculture"
      )
    usda_data_provider.save!

    #create taxa
    #Algae already created
    taxon = Taxon.find_or_create_by_name("Pfiesteria piscicida")
    taxon = Taxon.find_or_create_by_name("Alexandrium catenella")
    
    #create chapter information
    chapter_names = ["Bloom information", "Dynamics of blooms (General information)", "Educational resource", "Fisheries closures (federal)", "General information", "HABCRA", "HABs in the news", "Links", "Monitoring", "Research", "Toxin detection (ELISA)", "Toxin detection (general info)", "Toxin detection (HPLC)", "Toxin detection (RBA)", "Toxin general information"]
    chapter_names.each do |chapter_name|
      chapter = Chapter.find_or_create_by_name(chapter_name)
      chapter.save!
    end
    
    
  end

  def self.down
    usda_data_provider = DataProvider.find_by_name("USDA")
    if (usda_data_provider)
      usda_data_provider.destroy
    end
    arnat_data_provider = DataProvider.find_by_name("ARNAT")
    if (arnat_data_provider)
      arnat_data_provider.destroy
    end
    nasa_data_provider = DataProvider.find_by_name("NASA")
    if (nasa_data_provider)
      nasa_data_provider.destroy
    end
    
  end
end
